<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
// Test for https://bugs.webkit.org/show_bug.cgi?id=20117
test(() => assert_selection(
  [
    '<div id="x">Div X</div>',
    '<div id="y">Div Y</div>',
    '<div id="z">Div Z</div>',
  ].join(''),
  selection => {
    const x = selection.document.getElementById('x');
    const y = selection.document.getElementById('y');
    selection.setBaseAndExtent(x, 1, y, 1);
  },
  [
    '<div id="x">Div X^</div>',
    '<div id="y">Div Y|</div>',
    '<div id="z">Div Z</div>',
  ].join('')), 'anchor < focus');

test(() => assert_selection(
  [
    '<div id="x">Div X</div>',
    '<div id="y">Div Y</div>',
    '<div id="z">Div Z</div>',
  ].join(''),
  selection => {
    const x = selection.document.getElementById('x');
    const y = selection.document.getElementById('y');
    selection.setBaseAndExtent(y, 1, x, 1);
  },
  [
    '<div id="x">Div X|</div>',
    '<div id="y">Div Y^</div>',
    '<div id="z">Div Z</div>',
  ].join('')), 'anchor > focus');
</script>
